package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.MeetingRoomService;
import service.impl.MeetingRoomServiceImpl;

@WebServlet("/servlet/UpdateMeetingRoomStatusServlet")
public class UpdateMeetingRoomStatusServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO 自动生成的方法存根
		
		//新建service层对象
		MeetingRoomService service=new MeetingRoomServiceImpl();
		//获取roomid和satus值
		int roomid=Integer.parseInt(req.getParameter("roomid"));
		int status=Integer.parseInt(req.getParameter("status"));
		
		//准备切换状态
		int  newStatus;
		if(status==0)
			newStatus=1;
		else {
			newStatus=0;
		}
		//调用service的切换状态方法updateStatus
		service.updateStatus(roomid,newStatus);
		//转向到查看会议室
		req.getRequestDispatcher("ViewAllMeetingRoomsServlet").forward(req, resp);
		
		
		
	}

}
